/*    
 * Copyright (c) 2013 ISoftStone, Inc.
 * All right reserved.
 *
 * 文件名：      IUserDao.java
 * 作者:     Jacky Wang
 * 创建日期： 2013-7-24 下午01:08:52
 * 版本：           
 *
 */
package com.isoftstone.industry.aaa.core.dao.assist;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.isoftstone.industry.persistance.bean.User;
import com.isoftstone.modules.core.persistence.IGenericDao;

/**
 *
 * @author jacky
 */
public interface UserDao extends IGenericDao<User, String>, UserDaoPlus
{
	@Query("select distinct u from User u inner join u.chargingItems as item where item.status=:status and (item.effDate <= :end and item.expDate >= :start)")
	List<User> findByChargingItemStatusAndDate(@Param("status") String status, @Param("start") Date start, @Param("end") Date end);
	
	@Query("select distinct u from User u inner join u.bills as bill where bill.payableAmount>0")
	List<User> findByBillPayableAmountGreaterThan0();
	
	@Query("select distinct u from AccountItem a inner join a.productInst as p inner join p.user as u where a.status=?1 and a.prePaid=?2 and a.billingCycle is null and a.payableAmount>0")
	List<User> findByAcctItemStatusAndPrepaid(String status, boolean prePaid);
}
